import requests
class Testlong():
    token=None
    def setup_method(self):
        print('前')
    def teardowm_method(self):
        print('后')
#登录
    def testdl(self):
        url='http://10.59.9.12:7001/api/public/login'
        data={"username":"13811033962","password":"123456"}
        r=requests.post(url=url,json=data)
        Testlong.token = "Bearer " +r.json()['data']['token']
        print(Testlong.token)
        print('登录成功',r.json())
#商品详情
    def testxq(self):
        url='http://10.59.9.12:7001/api/goods/view?id=32'
        r=requests.get(url=url)
        print('查看成功',r.json())
#加入购物车
    def testjr(self):
        url='http://10.59.9.12:7001/api/cart/add'
        data={"id":32,"sku_id":"","num":1}
        tou={'auth-token':Testlong.token,'content-type':'application/json'}
        r=requests.post(url=url,json=data,headers=tou)
        print('添加成功',r.json())
#确认订单
    def testqr(self):
        url='http://10.59.9.12:7001/api/order/confirm?id=316&type=cart&shipping_type=1'
        tou={'auth-token':Testlong.token,'content-type':'application/json'}
        r=requests.get(url=url,headers=tou)
        print(r.json())
#提交订单
    def testtj(self):
        url='http://10.59.9.12:7001/api/order/detail'
        data={"id":"3244"}
        tou={'auth-token':Testlong.token,'content-type':'application/json'}
        r=requests.post(url=url,headers=tou)
        print(r.json())